<?php

namespace App\searchRules;

use ScoutElastic\SearchRule;

class ReportSearchRule extends SearchRule
{
    /**
     * @inheritdoc
     */
    public function buildHighlightPayload()
    {
        return [
            "pre_tags" => ['<font color="red">'],
            "post_tags" => ['</font>'],
            'fields' => [
                "top_description" => ['type' => 'plain'],
                "middle_description" => ['type' => 'plain'],
                "bottom_description" => ['type' => 'plain'],
                "figure_description" => ['type' => 'plain'],
                "appearance_description" => ['type' => 'plain'],
                "technique_description" => ['type' => 'plain'],
                "attitude_description" => ['type' => 'plain'],
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function buildQueryPayload()
    {
        $query = $this->builder->query;
        return [
            "should" => [
                ["match" => ["top_description" => $query]],
                ["match" => ["middle_description" =>  $query]],
                ["match" => ["bottom_description" =>  $query]],
                ["match" => ["figure_description" => $query]],
                ["match" => ["appearance_description" =>  $query]],
                ["match" => ["technique_description" =>  $query]],
                ["match" => ["attitude_description" =>  $query]],
            ],
        ];
    }
}